/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.modeling.metabolicNetworks;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import combi.wip.sipper.modeling.Protein;
import combi.wip.sipper.modeling.reactions.Reaction;

public abstract class MetabolicNetworkWithEnzymes<C,R extends Reaction<C>, E extends Protein> extends MetabolicNetwork<C,R> {

	protected Map<String, Protein> enzymeSet;
	
	public void init() {
		enzymeSet = new HashMap<String,Protein>();
		super.init();	
	}
	
	public abstract void addEnzyme(Protein enz);
	public abstract void removeEnzyme(Protein enz);

	public abstract void addCatalyze(Protein enz, Reaction<C> reaction);
	public abstract Collection<Reaction<C>> getCatalysedReactions(Protein enz);
	public abstract Collection<Protein> getEnzymes(Reaction<?> reaction);
	public abstract void removeCatalyze(Protein enz, Reaction<C> reaction);

	
	public void deepCopy(MetabolicNetworkWithEnzymes<C, Reaction<C>, E> meta) {
		enzymeSet = new HashMap<String,Protein>();
		super.deepCopy(meta);
		for (Protein enz : meta.getEnzymeSet())
		{
			this.addEnzyme(enz);
			for (Reaction<C> r : meta.getCatalysedReactions(enz))
			{
				this.addCatalyze(enz,r);
			}
		}
	}

	public Collection<Protein> getEnzymeSet() {
		return enzymeSet.values();
	}

	public Protein getEnzyme(String id) {
		return enzymeSet.get(id);
	}
	
	public void clear()
	{
		super.clear();
		enzymeSet.clear();
	}

	public String toString()
	{
		return super.toString()+ ", " + this.getEnzymeSet().toString();
	}
}
